package com.suning.controller;

//import com.baomidou.mybatisplus.extension.activerecord.Model;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.suning.service.IndexService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.Map;

//import net.sf.jsqlparser.Model;

@Controller
@RequestMapping("/index")
public class IndexController {
    @Resource
    private IndexService indexService;
    @RequestMapping("/index")
    public String index(Model model,
                        @RequestParam(value = "psize",defaultValue = "1") int psize,
                        @RequestParam(value = "pageSize",defaultValue = "8") int pageSize){
        System.out.println("接收到一个浏览器请求......");

        Map<String, Page> resultMap = indexService.index(psize,pageSize);

        model.addAttribute("resultMap",resultMap);
        return "index";
    }
}
